package org.display.graphic
{
	import flash.display.MovieClip;
	import flash.text.*;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;
	import flash.events.*;
	
	import flash.utils.*
	import flash.geom.*

	public class Tf extends ShapeBase
	{
		private var _txt:TextField
		private var maskbg:MovieClip
		
		public function Tf()
		{
			this.addChild(creat())
			maskbg=new MovieClip()

			with(maskbg){
				graphics.clear()
				graphics.lineStyle(1,0x000000,0)
				graphics.beginFill(0xcccccc,0)
				graphics.drawRect(0,0,100,20)
				graphics.endFill()
			}
			this.addChild(maskbg)
				
			super()

			createMenuItems(["重命名","复制","最上层","最下层","删除"])
			
			setTimeout(function(){
				var rec:Rectangle=getBounds(parent)
				hitRec.x=rec.width-10
				hitRec.y=rec.height-10
			},100)
		}
		
		public function creat():TextField{
			
			_txt=new TextField()
			_txt.type=TextFieldType.INPUT
			_txt.border=true
			_txt.width=100
			_txt.height=20
			_txt.background=true
			_txt.selectable=true	

			return _txt
			
		}
		
		public override function redraw(w:Number,h:Number){
			
			_txt.width=w
			_txt.height=h
				
			maskbg.width=w
			maskbg.height=h
			
		}
		
		public override function setTxtField(){
			
			removeChild(txtField)
			_txt.text=txtField.text
			
		}
		
		
	}
}